package com.linghang.wusthelper.controller.jwc;

import com.linghang.wusthelper.annotation.AuthenToken;
import com.linghang.wusthelper.common.ServerResponse;
import com.linghang.wusthelper.service.JwcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author origin
 * 教务处controller
 */
@RestController
@RequestMapping(path = "/jwc")
public class JwcController {

    @Autowired
    private JwcService jwcService;

    //  登录
    @PostMapping(path = "/login")
    public ServerResponse login(@RequestParam(value = "stuNum",required = true) String stuNum,
                                @RequestParam(value = "password",required = true) String password){
        return jwcService.login(stuNum,password);
    }

    // 获取成绩
    @GetMapping(path = "/getgrade")
    @AuthenToken
    public ServerResponse getGrade(@RequestHeader(value = "token",required = true) String token) throws InterruptedException {
        return jwcService.getGrade(token);
    }

    //  获取学分统计
    @GetMapping(path = "/getcredit")
    @AuthenToken
    public ServerResponse getCredit(@RequestHeader(value = "token",required = true) String token) throws InterruptedException {
        return jwcService.getCredit(token);
    }

    //  获取课表
    @GetMapping(path = "/getcurriculum")
    @AuthenToken
    public ServerResponse getCurriculum(@RequestHeader(value = "token",required = true) String token,
                                        @RequestParam(value = "schoolTerm",required = true) String schoolTerm) throws InterruptedException {
        return jwcService.getCurriculum(token,schoolTerm);
    }

    //  获取学生信息
    @GetMapping(path = "/getstudentinfo")
    @AuthenToken
    public ServerResponse getStudentInfo(@RequestHeader(value = "token",required = true) String token){
        return jwcService.getStudentInfo(token);
    }

    //  更新学生信息
    @GetMapping(path = "updatestudentInfo")
    @AuthenToken
    public ServerResponse updateStudentInfo(@RequestHeader(value = "token",required = true) String token) throws InterruptedException {
        return jwcService.updateStudentInfo(token);
    }

    //  获取教务处公告列表
    @GetMapping(path = "/getannouncementlist")
    public ServerResponse getAnnouncement(@RequestParam(value = "pageNum",required = true,defaultValue = "1") int pageNum,
                                          @RequestParam(value = "pageSize",required = false,defaultValue = "15") int pageSize){
        return jwcService.getAnnouncementList(pageNum,pageSize);
    }

    //  获取教务处公告内容
    @GetMapping(path = "/getannouncementcontent")
    public ServerResponse getAnnouncementContent(@RequestParam(value = "announcementId",required = true) int announcementId){
        return jwcService.getAnnouncementContent(announcementId);
    }

    //  获取分享的课表
    @GetMapping(path = "/getsharecurriculum")
    @AuthenToken
    public ServerResponse getsharecurriculum(@RequestParam(value = "content",required = true) String content){
        return jwcService.getShareCurriculum(content);
    }

}
